import { call, put, takeEvery } from "redux-saga/effects"
import axios from 'axios'
function* watchSaga () {
  yield takeEvery("get-cinemalist", getcinemaList)
}

function* getcinemaList () {
  let res = yield call(getcinemaListAction)
  yield put({
    type: "change-cinemalist",
    payload: res
  })
}
function getcinemaListAction () {
  return axios({
    url: "https://m.maizuo.com/gateway?cityId=440300&ticketFlag=1&k=8621223",
    method: "get",
    headers: {
      'X-Client-Info': '{ "a": "3000", "ch": "1002", "v": "5.2.0", "e": "16588855641625945769246721", "bc": "440300" }',
      'X-Host': 'mall.film-ticket.cinema.list'
    }
  }).then(res => {
    // console.log(res.data.data.cinemas)
    // 执行dispatch
    return res.data.data.cinemas

  }).catch(err => {
    console.log(err)
  })

}

export default watchSaga